/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxinline.manager.pesquisar;

import br.com.foxinline.modelo.MicroArea;
import br.com.foxinline.servico.MicroAreaServico;
import br.com.foxinline.utilitario.Msg;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author ely
 */
@ManagedBean
@ViewScoped
public class ManagerPesquisarMicroArea {

    @EJB 
    MicroAreaServico microAreaServico;
    
    private MicroArea microArea;
    private List<MicroArea> microAreas;
    private MicroArea microAreaRemover;

    @PostConstruct
    public void init() {
        microArea = new MicroArea();
        microAreas = new ArrayList<MicroArea>();
    }

    public void pesquisar() {
        microAreas = microAreaServico.findMicroArea(microArea);
    }

    public void setRemoverMicroArea(MicroArea cid) {
        this.microAreaRemover = cid;
    }

    public void removerMicroArea() {
        try {
            microAreaRemover.setAtivo(Boolean.FALSE);
            microAreaServico.atualizar(microAreaRemover);
            microAreas.remove(microAreaRemover);
            Msg.messagemInfo(Msg.SuccessFull);
        } catch (Exception erro) {
        }
    }

    public MicroArea getMicroArea() {
        return microArea;
    }

    public void setMicroArea(MicroArea microArea) {
        this.microArea = microArea;
    }

    public List<MicroArea> getMicroAreas() {
        return microAreas;
    }

    public void setMicroAreas(List<MicroArea> microAreas) {
        this.microAreas = microAreas;
    }

    public MicroArea getMicroAreaRemover() {
        return microAreaRemover;
    }

    public void setMicroAreaRemover(MicroArea microAreaRemover) {
        this.microAreaRemover = microAreaRemover;
    }

}
